load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "settings",
    srcs = [
        "bool.go",
        "byte_size.go",
        "common.go",
        "doc.go",
        "duration.go",
        "encoding.go",
        "enum.go",
        "float.go",
        "int.go",
        "masked.go",
        "options.go",
        "protobuf.go",
        "registry.go",
        "setting.go",
        "string.go",
        "updater.go",
        "values.go",
        "version.go",
    ],
    embed = [":settings_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/settings",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/buildutil",
        "//pkg/util/envutil",
        "//pkg/util/humanizeutil",
        "//pkg/util/protoutil",
        "//pkg/util/syncutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_cockroachdb_redact//interfaces",
        "@com_github_gogo_protobuf//jsonpb",
        "@com_github_gogo_protobuf//proto",
        "@org_golang_x_exp//constraints",
    ],
)

go_test(
    name = "settings_test",
    size = "small",
    srcs = [
        "alias_test.go",
        "encoding_test.go",
        "internal_test.go",
        "settings_test.go",
        "validation_test.go",
    ],
    embed = [":settings"],
    deps = [
        "//pkg/testutils",
        "//pkg/testutils/skip",
        "//pkg/util/leaktest",
        "//pkg/util/protoutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_gogo_protobuf//proto",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)

proto_library(
    name = "settings_proto",
    srcs = ["encoding.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto:gogo_proto"],
)

go_proto_library(
    name = "settings_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/settings",
    proto = ":settings_proto",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto"],
)
